var Dateval = '',DateArr = [], DateText = '', DateTextArr = [];
var cld = new Calendar({
	el: '#Calendarbox',
	value: '' // 默认为当日开始
})

//完成时间选择
$('.button').click(function() {
	if(DateArr.length != 0){
		var msg = {
			'id':'msg_calend',
			'content': {
				DateArrString: Arrsort(DateArr).toString(),
				DateTextArr: DateTextArr.toString()
			}
		}
		vipspa.setMessage(msg);
		location.hash = 'setplan'; //路由对应页面
	}else{
		layer.open({content: '请选择还款日期',skin: 'msg',time: 2});
	}
});

//将时间日期格式数组排序
function Arrsort(arr){
	      var timestamps = [];
		    for(var i = 0;i<arr.length;i++){
		        timestamps.push(new Date(arr[i]).getTime())
		    }  
		    timestamps.sort(function(a,b){return b-a})
		    var newArr = timestamps.map(function(value){
		        var now = new Date(value);
		        var yy = now.getFullYear();      //年
		        var mm = now.getMonth() + 1;     //月
		        var dd = now.getDate();          //日
		        var clock = yy + "-";
		        if(mm<10){
		        	mm = '0'+mm;
		        }
		        clock += mm + "-";
		         if(dd<10){
		        	dd = '0'+dd;
		        }
		        clock += dd;
		        return clock
		    })
		    return newArr.reverse();
}